<template>
  <div>
    <h1>post one</h1>
    <form>
      <input type="text" name="name" v-model="name" />
      <input type="text" name="age" v-model="age" />
      <input type="submit" value="提交" @click.prevent="submit" />
    </form>
  </div>
</template>

<script>
import { postTest } from "../api/ajax.js";
export default {
  data() {
    return { name: "", age: 0 };
  },
  methods: {
    submit() {
      const data = {};
      data.name = this.name;
      data.age = this.age * 1;
      const Jdata = JSON.stringify(data);
      const url = "/api/login";

      //传入实参
      postTest(this, url, Jdata);
    }
  }
};
</script>

<style></style>
